﻿<UserControl x:Class="OpenWPFChart.Helpers.ChooseColorDialog.KnownColorPicker"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:OpenWPFChart.Helpers.ChooseColorDialog"
	Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
	
	<UserControl.Resources>
		<local:KnownColorPickerColorToNamedColorConverter x:Key="colorToNamedColorConverter"/>
	</UserControl.Resources>
	
	<StackPanel Name="contentHost">
		<TextBlock Margin="5,5,0,0">Base Colors</TextBlock>
		<ListBox
				ItemsSource="{Binding Path=BaseColors}"
				SelectedItem="{Binding Path=SelectedColor, Converter={StaticResource colorToNamedColorConverter}}"
				>
			<ListBox.Background>
				<LinearGradientBrush StartPoint="0, 0.5" EndPoint="1, 0.5">
					<GradientStop Offset="0" Color="White"/>
					<GradientStop Offset="1" Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}"/>
				</LinearGradientBrush>
			</ListBox.Background>
			<ListBox.ItemsPanel>
				<ItemsPanelTemplate>
					<UniformGrid Columns="8"/>
				</ItemsPanelTemplate>
			</ListBox.ItemsPanel>
			<ListBox.ItemTemplate>
				<DataTemplate>
					<Rectangle Height="20" Width="20" Margin="3"
											   ToolTip="{Binding Name}">
						<Rectangle.Fill>
							<SolidColorBrush Color="{Binding Color}"/>
						</Rectangle.Fill>
					</Rectangle>
				</DataTemplate>
			</ListBox.ItemTemplate>
		</ListBox>

		<TextBlock Margin="5,5,0,0">All WellKnown Colors</TextBlock>
		<ComboBox Grid.IsSharedSizeScope="True"
								ItemsSource="{Binding Path=WellKnownColors}"
								SelectedItem="{Binding Path=SelectedColor, Converter={StaticResource colorToNamedColorConverter}}"
								 >
			<ComboBox.ItemTemplate>
				<DataTemplate>
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto" SharedSizeGroup="colorNames"/>
							<ColumnDefinition SharedSizeGroup="colors"/>
						</Grid.ColumnDefinitions>
						<TextBlock Text="{Binding Name}" Margin="1"/>
						<Rectangle Grid.Column="1" Height="15" Width="15" Margin="1">
							<Rectangle.Fill>
								<SolidColorBrush Color="{Binding Color}"/>
							</Rectangle.Fill>
						</Rectangle>
					</Grid>
				</DataTemplate>
			</ComboBox.ItemTemplate>
		</ComboBox>
	</StackPanel>
</UserControl>
